

/**
 * 
 * @param {Array} allRoutes 用户的完整路由表(需要进行权限控制的路由表)
 * @param {Array} menulist 后台返回的菜单数据
 */

export default function recursionRoutes(allRoutes = [], menulist = []) {


    let userRoutes = [];

    menulist.forEach(menuItem => {
        allRoutes.forEach(routeItem => {
            if (menuItem.title === routeItem.meta.key) {
              
                if (menuItem.children && menuItem.children.length > 0) {

                    routeItem.children = recursionRoutes(routeItem.children, menuItem.children)
                }

                userRoutes.push(routeItem)
            }
        })
    })

    return userRoutes
}